/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package YottaTron;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.Serializable;

/**
 *
 * @author Cenda
 */
public class AnimatedGraphicsLoader extends GraphicsLoader{

    public BufferedImage[] images;
    public int numImages;

    public AnimatedGraphicsLoader(String fileName, int numImages) throws IOException {
        super(fileName);
        int pieceWidth = im.getWidth() / numImages;
        int pieceHeight = im.getHeight();
        Graphics2D pieceGC;
        this.numImages = numImages;
        images = new BufferedImage[numImages];

        for (int i = 0; i < numImages; i++) {
            images[i] = gc.createCompatibleImage(pieceWidth, pieceHeight, transparency);
            pieceGC = images[i].createGraphics();
            pieceGC.drawImage(im, 0, 0,pieceWidth,pieceHeight,i*pieceWidth,0,(i*pieceWidth)+pieceWidth,pieceHeight,null);
            pieceGC.dispose();
        }
    }

    public AnimatedGraphicsLoader(String fileName, String shapeFileName, int numImages) throws IOException {
        super(fileName,shapeFileName);
        int pieceWidth = im.getWidth() / numImages;
        int pieceHeight = im.getHeight();
        Graphics2D pieceGC;
        this.numImages = numImages;
        images = new BufferedImage[numImages];

        for (int i = 0; i < numImages; i++) {
            images[i] = gc.createCompatibleImage(pieceWidth, pieceHeight, transparency);
            pieceGC = images[i].createGraphics();
            pieceGC.drawImage(im, 0, 0,pieceWidth,pieceHeight,i*pieceWidth,0,(i*pieceWidth)+pieceWidth,pieceHeight,null);
            pieceGC.dispose();
        }
    }
}
